package com.zrrd.gmall.webll.controller;

import com.zrrd.gmall.common.result.Result;
import com.zrrd.gmall.item.fegin.ItemFeginClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
public class WebController {

    @Autowired
    private ItemFeginClient itemFeginClient;

    //商品详情
    @GetMapping("{skuId}.html")
    public String getItem(@PathVariable("skuId") Long skuId, Model model){
        //1.使用fegin对象请求商品汇总服务
        Result<Map> result = itemFeginClient.getItem(skuId);
        //2.将获取的数据存入到model对象中
        model.addAllAttributes(result.getData());
        //3.带着model对象的数据转发到详情页面
        return "/item/index";
    }
}
